from django.contrib import admin
from .models import Server, MonitorLog, Asset, AssetCategory, ResponsiblePerson

@admin.register(Server)
class ServerAdmin(admin.ModelAdmin):
    list_display = ('name', 'ip_address', 'status', 'last_check')
    list_filter = ('status',)
    search_fields = ('name', 'ip_address')

@admin.register(MonitorLog)
class MonitorLogAdmin(admin.ModelAdmin):
    list_display = ('server', 'cpu_usage', 'memory_usage', 'disk_usage', 'timestamp')
    list_filter = ('server',)
    date_hierarchy = 'timestamp'

@admin.register(AssetCategory)
class AssetCategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'description')
    search_fields = ('name',)

@admin.register(Asset)
class AssetAdmin(admin.ModelAdmin):
    list_display = ('asset_number', 'name', 'category', 'status', 'location', 'responsible_person', 'purchase_date')
    list_filter = ('category', 'status', 'location')
    search_fields = ('name', 'asset_number', 'responsible_person__name')
    date_hierarchy = 'purchase_date'
    ordering = ('-created_at',)

@admin.register(ResponsiblePerson)
class ResponsiblePersonAdmin(admin.ModelAdmin):
    list_display = ('name', 'department', 'phone', 'email')
    search_fields = ('name', 'phone', 'email', 'department')
    ordering = ('name',) 